﻿using StackOverflow.IDAL;
using StackOverflow.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StackOverflow.DalFactory
{

    /// <summary>
    /// 
    /// </summary>
    public class DbSession :IDbSession
    {
        /// <summary>
        /// 创建操作的DbContext
        /// </summary>
        /// <value>
        /// The database.
        /// </value>
        public DbContext Db
        {
            get
            {
                return new LocalData();
            }
        }
        /// <summary>
        /// 创建UserInfo的EF数据操作类
        /// </summary>
        /// Author:bishisan
        /// Date:2017/8/31
        private IUserInfoDal _userInfoDal;
        public IUserInfoDal UserInfoDal
        {
            get => AbstractFactory.CreateUserInfoDal();
            set => _userInfoDal = value;
        }
       



        /// <summary>
        /// 单元工厂模式
        /// </summary>
        /// <returns></returns>
        /// Author:bishisan
        /// Date:2017/8/31
        public bool SaveChanges()
        {
            return Db.SaveChanges() > 0;
        }

    }
}
